package com.woniuxy.user.mapper;

import com.woniuxy.commons.entity.UserLike;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

/**
 * @Author:阳佳
 * @Date: 2020/7/20 9:52
 * @Description:点赞相关操作
 * @PACKAGE_NAME:com.woniuxy.user.mapper
 */
@Repository
public interface UserLikeMapper {
    /*
    用户点赞操作 用户点击后点赞按钮后 将相关信息写入数据库中
     */
    @Insert("insert into user_like values(default,#{uid},#{cid})")
    public int addLikeRecord(UserLike userLike);

    /*
    取消点赞 删除某个人某条课程点赞数据
     */
    @Delete("delete from user_like where uid=#{uid} and cid=#{cid}")
    public int delLikeRecordByCidAndUid(@Param("uid") String uid, @Param("cid") String cid);


    /*
    统计某个课程点赞人数
     */
    @Select("select count(*) from user_like where cid=#{cid}")
    public int courseLikeCountByCid(@Param("cid") String cid);

    /*
   查询某个人对课程的点赞情况
    */
    @Select("select * from user_like where cid=#{cid} and uid=#{uid}")
    public UserLike findCourseLikeRecordByCidAndUid(@Param("cid") String cid, @Param("uid") String uid);
}


